<template>
name:<input v-model="userName"/>
passwd<input  v-model="password"/>
<button @click="login">login</button>
</template>
<script setup lang="ts">
import { useLoginUserStore } from '@/stores/loginUser';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter()
const loginUserStore = useLoginUserStore()
const userName = ref('')
const password = ref('')
const login = () => {
    loginUserStore.login(userName.value,password.value).then(res => {
        const data = res.data
        if(data.code == '200'){
            loginUserStore.setUser({
                userName:userName.value,
                token:data.token
            })
            router.push("/")
        }else {
            console.log(data.msg);
            
        }
    })
}
</script>
<style scoped>
</style>